# $Id$
# Maintainer: Laurent Carlier <lordheavym@gmail.com>

pkgname=spirv-tools
pkgver=2016.6
# SPIRV-Tools is unhelpfully versioned using commit messages like so:
# https://github.com/KhronosGroup/SPIRV-Tools/commit/5f5fa3a3f1009f0db845d0c9ed76a39fcfe5b20c
_commit=5f5fa3a3f1009f0db845d0c9ed76a39fcfe5b20c
_spirv_headers_commit=c470b68225a04965bf87d35e143ae92f831e8110
pkgrel=2
pkgdesc="API and commands for processing SPIR-V modules"
arch=('i686' 'x86_64')
url="https://www.khronos.org/vulkan/"
license=('custom')
groups=(vulkan-devel)
depends=(gcc-libs)
makedepends=(cmake python git)
source=("git+git://github.com/KhronosGroup/SPIRV-Tools.git#commit=${_commit}"
        "git+git://github.com/KhronosGroup/SPIRV-Headers.git#commit=${_spirv_headers_commit}")
sha256sums=('SKIP'
            'SKIP')

prepare() {
  cd SPIRV-Tools
  # Fix build with GCC 7
  git cherry-pick -n 01b28750bf8ecda48e0f2f6a16d0363450e205d9
}

build() {
  cd SPIRV-Tools

  rm -rf build && mkdir build && cd build
  cmake .. \
      -DCMAKE_INSTALL_PREFIX=/usr \
      -DCMAKE_BUILD_TYPE=Release \
      -DSPIRV-Headers_SOURCE_DIR=${srcdir}/SPIRV-Headers
  make
}

package() {
  cd SPIRV-Tools/build

  make DESTDIR="${pkgdir}" install

  install -dm755 "${pkgdir}/usr/share/licenses/${pkgname}"
  install -m644 ../LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/"
}
